package com.qk.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Slf4j
@Component
public class TokenInterceptor implements HandlerInterceptor {
   /* @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

     *//*   String requestURL = request.getRequestURI();
        if(requestURL.contains("login"))
        {
            log.info("用户登陆: {}" , requestURL);
            return  true;
        }*/

    /*
        String jwt = request.getHeader("token");
        if(jwt == null || jwt.isEmpty())
        {
            log.info("请求头token不存在");
            response.setStatus(401);
            return false;
        }
        try
        {
            Claims claims = JwtUtils.parseToken(jwt);
            log.info("解析成功: {}" , claims);
            CurrentUserHoler.setCurrentUser(claims.get("id",Integer.class));
        } catch (Exception e)
        {
            log.info("解析失败: {}" , e.getMessage());
            response.setStatus(401);
            return false;
        }
        return true;
        @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        CurrentUserHoler.removeCurrentUser();
    }
    }*/
    }